package com.yesjpt.web;

import com.yesjpt.domain.Lxfs;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Date;

@RestController
@RequestMapping("/http") // 上下文路径
public class HttpController {

    @GetMapping("/get/{key}") //路径参数
    public Object setSession(@PathVariable String key) {
        System.out.println(new Throwable().getStackTrace()[0]);
        return key;
    }

    @PutMapping("/put")
    public Object put(@RequestBody Lxfs vo) {
        System.out.println(new Throwable().getStackTrace()[0]);
        return vo;
    }
    @GetMapping("/setSession")
    public Object setSession(HttpSession session) {
        System.out.println(new Throwable().getStackTrace()[0]);
        Lxfs lxfs = new Lxfs();
        lxfs.setAddr("林湾");
        lxfs.setEmail("293440@qq.com");
        lxfs.setPhone("13709088388");
        lxfs.setBirth(new Date());
        session.setAttribute("lxfs", lxfs);
        session.setAttribute("password", "123456");
        return lxfs;
    }
    @GetMapping("/getSession")
    public Object setSession(HttpSession session, String key) {
        System.out.println(new Throwable().getStackTrace()[0]);
        return session.getAttribute(key);
    }

}
